﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;

namespace VitCode.BaseDataPageCreator
{
    public class SessionObjectHelper
    {

        public static void SetSession(Page p,string key,object val)
        {
            p.Session[p.Request.RawUrl + key] = val;
        }

        public static object GetSession(Page p,string key)
        {
            string keyVal = p.Request.RawUrl + key;
            if (p.Session[keyVal] != null)
                return p.Session[keyVal];
            return null;
        }

        public static void SetSession(Control ctl, string key, object val)
        {
            HttpContext.Current.Session[ctl.Page.ID+ctl.ID+key] = val;
        }

        public static object GetSession(Control ctl, string key)
        {
            string keyVal = ctl.Page.ID + ctl.ID + key;
            if (HttpContext.Current.Session[keyVal] != null)
                return HttpContext.Current.Session[keyVal];
            return null;
        }
    }
}
